# -*- coding:UTF-8 -*-#

'''
@author: qianwp
'''

class SQLUID:
    MaxCustId = 'select max(cust_id) from t_customer where cust_id between %s and %s'
    MaxAlbumId = 'select max(album_id) from t_album where album_id between %s and %s'
    MaxCompstId = 'select max(composit_id) from t_composit where composit_id between %s and %s'
    MaxPhotoId = 'select max(photo_id) from t_photo where photo_id between %s and %s'
    MaxCommentId = 'select max(comment_id) from t_comment where comment_id between %s and %s'
    
class SQLLogin:
    CheckEmail = 'select count(1) from t_customer where email = %s'
    CheckNick = 'select count(1) from t_customer where nick = %s'
    GetCustomerByEmail = 'select cust_id,email,nick,passwd,reg_date,login_date,upgraded from t_customer where email=%s'
    GetCustomerById = 'select cust_id,email,nick,passwd,reg_date,login_date,upgraded from t_customer where cust_id=%s'
    AddCustomer = 'insert into t_customer(cust_id,email,nick,passwd,reg_date,login_date,upgraded) values(%s,%s,%s,%s,%s,%s,%s)'

class SQLCustomer:
    UpgradeCustomer = 'update t_customer set upgraded = %s where cust_id = %s'
    UpdateLoginDate = 'update t_customer set login_date = %s where cust_id=%s'
    UpdatePasswd = 'update t_customer set passwd = %s where cust_id=%s'
    
class SQLDesigner:
    GetDesigner = 'select cust_id,real_name,ident_num,contact_num,address,create_date from t_designer where cust_id=%s'
    AddDesigner = 'insert into t_designer(cust_id,real_name,ident_num,contact_num,address,create_date) values(%s,%s,%s,%s,%s,%s)'
    
class SQLAlbum:
    AddAlbum = 'insert into t_album(album_id,cust_id,album_name,create_date) values(%s,%s,%s,%s)'
    GetAlbumById = 'select album_id,cust_id,album_name,create_date from t_album where album_id=%s'
    GetAlbumIdsByCustId = 'select album_id from t_album where cust_id=%s'
    GetAlbumsByCustId = 'select album_id,cust_id,album_name,create_date from t_album where cust_id=%s'
    RemoveAlbumById = 'delete from t_album where album_id=%s'
    UpdateAlbumName = 'update t_album set album_name=%s where album_id=%s'
    
class SQLComposit:
    AddComposit = 'insert into t_composit(composit_id,composit_name,cust_id,album_id,create_date) values(%s,%s,%s,%s,%s)'
    GetCompositById = 'select composit_id,composit_name,cust_id,album_id,create_date from t_composit where composit_id=%s'
    GetCompositIdsByAlbumId = 'select composit_id from t_composit where album_id=%s'
    GetCompositsByAlbumId = 'select composit_id,composit_name,cust_id,album_id,create_date from t_composit where album_id=%s'
    RemoveCompositById = 'delete from t_composit where composit_id=%s'
    UpdateCompositName = 'update t_composit set composit_name=%s where composit_id=%s'
    
class SQLPhoto:
    AddPhoto = 'insert into t_photo(photo_id,photo_url,create_date,composit_id,album_id,cust_id) values(%s,%s,%s,%s,%s,%s)'
    GetPhotoById = 'select photo_id,photo_url,create_date,composit_id,album_id,cust_id from t_photo where photo_id=%s'
    GetPhotoIdsByCompositId = 'select photo_id from t_photo where composit_id=%s'
    GetPhotosByCompositId = 'select photo_id,photo_url,create_date,composit_id,album_id,cust_id from t_photo where composit_id=%s'
    RemovePhotoById = 'delete from t_photo where photo_id=%s'
    UpdatePhotoUrl = 'update t_photo set photo_url=%s where photo_id=%s'
    
class SQLComment:
    AddComment = 'insert into t_comment(comment_id,composit_id,content,from_cust_id,create_date) values(%s,%s,%s,%s,%s)'
    GetCommentById = 'select comment_id,composit_id,content,from_cust_id,create_date from t_comment where comment_id=%s'
    GetCommentIdsByCompositId = 'select comment_id from t_comment where composit_id=%s'
    GetCommentsByCompositId = 'select comment_id,composit_id,content,from_cust_id,create_date from t_comment where composit_id=%s'
    RemoteCommentById = 'delete from t_comment where comment_id=%s'
    
